package com.server.dao.impl;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;






public class BasicDao {
     private String url="jdbc:mysql://localhost:3306/db_educate";
     private String user="root";
     private String password="a123";
     
     public Connection getConnection(){
    	 Connection conn=null;
    	 try {
			Class.forName("com.mysql.jdbc.Driver");
		    conn=DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	 return conn;
     }
     
     public void closeAll(ResultSet rs,PreparedStatement prs,Connection conn) throws SQLException{
    	 if(rs!=null){
    		rs.close(); 
    	 }else if(prs!=null){
    		 prs.close();
    	 }else{
    		 conn.close();
    	 }
     }
}
